<%-- 
    Document   : profile
    Created on : Jan 16, 2013, 1:26:21 PM
    Author     : SONY
--%>

<%@page import="service.UserLoginServiceLocal"%>
<%@page import="entity.UserLogin"%>
<%@page import="entity.MemberCustomer"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%
    String error = "";
    if(request.getAttribute("error") != null) {
        error = request.getAttribute("error").toString();
    }
%>
<p style="font-weight:bold;color:red;"><%=error%></p>
<%-- Report any errors (if any) --%>
<html:errors />
<% 
    MemberCustomer member = (MemberCustomer) session.getAttribute("user_member");
    UserLoginServiceLocal userLoginServiceLocal = (UserLoginServiceLocal) application.getAttribute("userLoginServiceLocal");
    UserLogin user = userLoginServiceLocal.getUserLoginDetails_byMemberID(member.getMemberID());
    String email = user.getEmailAddress();
    String firstName = member.getFirstName();   
    String lastName = member.getLastName();   
    String gender = member.getGender();
    String address = member.getAddress();    
    String phone = member.getPhone();  
%>
<br/>
<br/>
<%-- Generate main body --%>
<html:form action="/member/profile.do" method="POST" acceptCharset="UTF-8">
    <fieldset class="register">
        <legend class="lgend">Thông Tin Tài Khoản</legend>
    <table width=400 border=0 cellpadding="5px">
        <tr>
            <td width=200><span class="required">*&nbsp;</span>Email</td>
            <td width=200>
                <%-- Repopulate the Email field --%>
                <html:text property="email" value="<%=email%>" readonly="true" styleClass="txtMask" style="width: 200px;" />
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
                <html:checkbox property="changePass"  /> Thay Đổi Mật Khẩu
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Mật Khẩu Hiện Tại</td>
            <td>
                <%-- Repopulate the Password field --%>
                <html:password property="passwordOld" styleClass="txtMask" style="width: 200px;" />
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Mật Khẩu Mới</td>
            <td>
                <%-- Repopulate the Password field --%>
                <html:password property="passwordNew" styleClass="txtMask" style="width: 200px;" />
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Nhập Lại Mật Khẩu Mới</td>
            <td>
                <%-- Repopulate the Password field --%>
                <html:password property="confirmpassNew" styleClass="txtMask" style="width: 200px;" />
            </td>
        </tr>
    </table>
    </fieldset>
    <p>&nbsp;</p>
    <fieldset class="register" style="width: 580px;">
        <legend class="lgend">Thông Tin Giao Hàng</legend>
    <table width=550 border=0 cellpadding="5px">
        <tr>
            <td width=200><span class="required">*&nbsp;</span>Họ và Chữ Lót</td>
            <td width=350>
                <%-- Repopulate the LastName field --%>
                <html:text property="lastName" value="<%=lastName%>" styleClass="txtMask" style="width: 200px;" />
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Tên</td>
            <td>
                <%-- Repopulate the FirstName field --%>
                <html:text property="firstName" value="<%=firstName%>" styleClass="txtMask" style="width: 200px;" />
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Giới Tính<br /></td>
            <td>
                <%-- Repopulate the Gender drop-down menu --%>
                <html:select property='gender' styleClass="txtMask" style="width: 60px;">
                    <% if(gender.equals("F")) { %>
                        <html:option value="F">Nữ</html:option>
                        <html:option value="M">Nam</html:option>
                    <% } else { %>                       
                        <html:option value="M">Nam</html:option>
                        <html:option value="F">Nữ</html:option>
                    <% } %>
                </html:select>
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Điện Thoại Liên Hệ</td>
            <td>
                <%-- Repopulate the Phone field --%>
                <html:text property="phone" value="<%=phone%>" styleClass="txtMask" style="width: 200px;" />
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Địa Chỉ</td>
            <td>
                <%-- Repopulate the Street field --%>
                <html:text property="address" value="<%=address%>" styleClass="txtMask" style="width: 350px;" />
            </td>
        </tr>
        <tr>
            <td colspan=2 align=center style="padding-top: 10px">
                
            </td>
        </tr>
    </table>
    </fieldset>
                <%-- The submit button --%>
                <html:submit style="margin-left: 230px; margin-top: 10px;" value="Cập Nhật" styleClass="btnMask"/>
</html:form>
<% 
if(((HttpServletRequest) request).getAttribute("success") != null) {
    String success = ((HttpServletRequest) request).getAttribute("success").toString();
    if(success.length() > 0) { 
        out.println("<script type=\"text/javascript\">");
        out.println("alert(\"" + success + "\")");
        out.println("</script>");
    }
} %>
